import requset from '@/utils/request'

/**
 * 获取推荐文章数据
 * @returns 
 */
export const getRecommendListService = () => {
    return requset.get('/user/article/recommend')
}

/**
 * 获取最近更新文章数据
 * @returns 
 */
export const getLatestListService = () => {
    return requset.get('/user/article/latest')
}

/**
 * 根据id查询文章数据
 * @param {*} id 
 * @returns 
 */
export const getArticleByIdService = (id) => {
    return requset.get(`/user/article/${id}`)
}

/**
 * 分页查询所有可用文章数据
 * @param {*} query 
 * @returns 
 */
export const getArticleListService = (query) => {
    return requset.get('/user/article', {
        params: query
    })
}

/**
 * 查询对应文章的评论数据
 * @param {*} articleId 
 * @returns 
 */
export const getArticleCommentService = (articleId) => {
    return requset.get(`/user/article/comments/${articleId}`)
}

/**
 * 用户评论文章数据
 * @param {*} comment 
 * @returns 
 */
export const userAddArticelCommentService = (comment) => {
    return requset.post('/user/article/user/comment', comment)
}

/**
 * 用户点赞文章
 * @param {*} id 
 * @returns 
 */
export const userAddArticleLikeService = (id) => {
    return requset.put(`/user/article/user/like/${id}`)
}